home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / OutOfPhase1.01Source / OutOfPhase Folder / SampleObject.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  6.8 KB  |  158 lines  |  [TEXT/KAHL]

  1. /* SampleObject.h */
  2.  
  3. #ifndef Included_SampleObject_h
  4. #define Included_SampleObject_h
  5.  
  6. /* SampleObject module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* DataMunging */
  13. /* SampleList */
  14. /* SampleWindow */
  15. /* FixedPoint */
  16. /* SampleConsts */
  17. /* SampleStorageActual */
  18. /* MainWindowStuff */
  19. /* BufferedFileInput */
  20. /* BufferedFileOutput */
  21.  
  22. #include "SampleConsts.h"
  23. #include "FixedPoint.h"
  24. #include "MainWindowStuff.h"
  25.  
  26. struct SampleObjectRec;
  27. typedef struct SampleObjectRec SampleObjectRec;
  28.  
  29. /* forward declarations */
  30. struct MainWindowRec;
  31. struct CodeCenterRec;
  32. struct SampleListRec;
  33. struct SampleStorageActualRec;
  34. struct BufferedInputRec;
  35. struct BufferedOutputRec;
  36.  
  37. /* allocate and create a new empty sample object, with reasonable defaults */
  38. SampleObjectRec*            NewSampleObject(struct CodeCenterRec* CodeCenter,
  39.                                                 struct MainWindowRec* MainWindow,
  40.                                                 struct SampleListRec* SampleList);
  41.  
  42. /* allocate and create a sample object with the specified attributes */
  43. /* the RawData field must not be NIL.  It will be copied for the new sample */
  44. SampleObjectRec*            NewSampleObjectInitialized(struct CodeCenterRec* CodeCenter,
  45.                                                 struct MainWindowRec* MainWindow,
  46.                                                 struct SampleListRec* SampleList, char* DataToCopy,
  47.                                                 NumBitsType NumBits, NumChannelsType NumChannels, long Origin,
  48.                                                 long LoopStart1, long LoopStart2, long LoopStart3,
  49.                                                 long LoopEnd1, long LoopEnd2, long LoopEnd3, long SamplingRate,
  50.                                                 double NaturalFrequency);
  51.  
  52. /* dispose of a sample object */
  53. void                                    DisposeSampleObject(SampleObjectRec* SampObj);
  54.  
  55. /* find out if sample object has been modified */
  56. MyBoolean                            HasSampleObjectBeenModified(SampleObjectRec* SampObj);
  57.  
  58. /* get a copy of the sample's name. */
  59. char*                                    SampleObjectGetNameCopy(SampleObjectRec* SampObj);
  60.  
  61. /* set the sample's name.  the object becomes the owner of the Name block so */
  62. /* the caller should not release it. */
  63. void                                    SampleObjectNewName(SampleObjectRec* SampObj, char* Name);
  64.  
  65. /* get a copy of the formula applied to the sample */
  66. char*                                    SampleObjectGetFormulaCopy(SampleObjectRec* SampObj);
  67.  
  68. /* install a new formula into the sample.  the object becomes the owner of the */
  69. /* formula, so the caller should not release it */
  70. void                                    SampleObjectNewFormula(SampleObjectRec* SampObj, char* Formula);
  71.  
  72. /* get the number of bits in a channel for the sample */
  73. NumBitsType                        SampleObjectGetNumBits(SampleObjectRec* SampObj);
  74.  
  75. /* get the number of channels in the sample */
  76. NumChannelsType                SampleObjectGetNumChannels(SampleObjectRec* SampObj);
  77.  
  78. /* get the loop control values.  if the loop end and loop start are the same, */
  79. /* then there is no loop */
  80. long                                    SampleObjectGetOrigin(SampleObjectRec* SampObj);
  81. long                                    SampleObjectGetLoopStart1(SampleObjectRec* SampObj);
  82. long                                    SampleObjectGetLoopStart2(SampleObjectRec* SampObj);
  83. long                                    SampleObjectGetLoopStart3(SampleObjectRec* SampObj);
  84. long                                    SampleObjectGetLoopEnd1(SampleObjectRec* SampObj);
  85. long                                    SampleObjectGetLoopEnd2(SampleObjectRec* SampObj);
  86. long                                    SampleObjectGetLoopEnd3(SampleObjectRec* SampObj);
  87.  
  88. /* get sample attributes */
  89. long                                    SampleObjectGetSamplingRate(SampleObjectRec* SampObj);
  90. double                                SampleObjectGetNaturalFrequency(SampleObjectRec* SampObj);
  91.  
  92. /* get the number of sample frames */
  93. long                                    SampleObjectGetNumSampleFrames(SampleObjectRec* SampObj);
  94.  
  95. /* get a pointer to the raw data for the sample.  this pointer is the */
  96. /* actual data, not a copy, so don't dispose of it.  if any operations are performed */
  97. /* on the sample, this pointer may become invalid.  format of raw data: */
  98. /*  - mono, 8-bit:  array of signed bytes */
  99. /*  - stereo, 8-bit:  array of signed bytes, grouped in pairs.  the one lower in */
  100. /*    memory is the left channel */
  101. /*  - mono, 16-bit:  array of signed short integers (either 2 or 4 bytes) */
  102. /*  - stereo, 16-bit:  array of signed short integers, grouped in pairs.  the one */
  103. /*    lower in memory is the left channel */
  104. char*                                    SampleObjectGetRawData(SampleObjectRec* SampObj);
  105.  
  106. /* put new data into the sample.  the num channels, bits, and data has to be put */
  107. /* in all at the same time so that no reformatting routines need to be supplied. */
  108. /* the object becomes owner of the data block, so it must not be released by the */
  109. /* caller.  this call should also be made BEFORE any of the calls to set the */
  110. /* attributes, since the attribute's values will be constrained based on this data */
  111. void                                    SampleObjectPutNewSample(SampleObjectRec* SampObj,
  112.                                                 struct SampleStorageActualRec* NewStorage);
  113.  
  114. /* change the loop control values and attributes */
  115. void                                    SampleObjectPutOrigin(SampleObjectRec* SampObj, long Origin);
  116. void                                    SampleObjectPutLoopStart1(SampleObjectRec* SampObj, long LoopStart);
  117. void                                    SampleObjectPutLoopStart2(SampleObjectRec* SampObj, long LoopStart);
  118. void                                    SampleObjectPutLoopStart3(SampleObjectRec* SampObj, long LoopStart);
  119. void                                    SampleObjectPutLoopEnd1(SampleObjectRec* SampObj, long LoopEnd);
  120. void                                    SampleObjectPutLoopEnd2(SampleObjectRec* SampObj, long LoopEnd);
  121. void                                    SampleObjectPutLoopEnd3(SampleObjectRec* SampObj, long LoopEnd);
  122. void                                    SampleObjectPutSamplingRate(SampleObjectRec* SampObj,
  123.                                                 long SamplingRate);
  124. void                                    SampleObjectPutNaturalFrequency(SampleObjectRec* SampObj,
  125.                                                 double NaturalFrequency);
  126.  
  127. /* call which makes object open its editor window */
  128. MyBoolean                            SampleObjectOpenWindow(SampleObjectRec* SampObj);
  129.  
  130. /* this is called by the window when it is closing to notify the object. */
  131. /* the object should not take any action. */
  132. void                                    SampleObjectClosingWindowNotify(SampleObjectRec* SampObj,
  133.                                                 short NewXSize, short NewYSize, short NewWidth, short NewHeight);
  134.  
  135. /* obtain fixed point array of data.  NIL is returned if there isn't enough memory. */
  136. largefixedsigned*            SampleObjectGetLeftFixed(SampleObjectRec* SampObj);
  137. largefixedsigned*            SampleObjectGetRightFixed(SampleObjectRec* SampObj);
  138. largefixedsigned*            SampleObjectGetMonoFixed(SampleObjectRec* SampObj);
  139.  
  140. /* the document's name has changed, so the window needs to be updated */
  141. void                                    SampleObjectGlobalNameChange(SampleObjectRec* SampObj,
  142.                                                 char* NewFilename);
  143.  
  144. /* read a sample object from the file */
  145. FileLoadingErrors            SampleObjectNewFromFile(SampleObjectRec** ObjectOut,
  146.                                                 struct BufferedInputRec* Input, struct CodeCenterRec* CodeCenter,
  147.                                                 struct MainWindowRec* MainWindow,
  148.                                                 struct SampleListRec* SampleList);
  149.  
  150. /* write the data in a sample object out to the file */
  151. FileLoadingErrors            SampleObjectWriteOutData(SampleObjectRec* SampObj,
  152.                                                 struct BufferedOutputRec* Output);
  153.  
  154. /* mark sample object as not modified */
  155. void                                    SampleObjectMarkAsSaved(SampleObjectRec* SampObj);
  156.  
  157. #endif
  158.